# -*- coding: utf-8 -*-
# @Time    : 2024/1/15  14:53
# @Author  : zhanghao
# @FileName: task_api.py
# @Software: PyCharm
"""
    Description: 定义服务相关http接口
"""
from fastapi import FastAPI, Query
from api.request.task_request import TaskReq
from api.request.config_rule import ConfigRule
from db.task_manager import TaskManager
from config.logger import Logger

import sqlite3

app = FastAPI()
task_manager = TaskManager()
logger = Logger.get()


@app.post("/api/config/update")
def taskSubmit(config_rule: ConfigRule):
    logger.info(config_rule)
    logger.info('configUpdate ......' + str(config_rule.classifyId))
    return task_manager.configRule(config_rule)

@app.post("/api/task/submit")
def taskSubmit(task_req: TaskReq):
    logger.info('taskSubmit ......' + task_req.link_type)
    return task_manager.taskSubmit(task_req)

@app.get("/api/task/query")
async def taskQuery(file_id: str = Query(..., title='请输入文件id')):
    logger.info('taskQuery ......' + file_id)
    return task_manager.taskQuery(file_id)



